home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Files / XTND 1.3.6 / Application Examples / CSource / TESample.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-06  |  8.1 KB  |  254 lines  |  [TEXT/MPS ]

  1. /************************************************************************
  2. *                                                                        *
  3. *    TESample.h                                                            *
  4. *                                                                        *
  5. *    Header file for the TESample application.                            *
  6. *                                                                        *
  7. *    Copyright © 1988 Claris Corporation                                    *
  8. *    All Rights Reserved                                                    *
  9. *                                                                        *
  10. ************************************************************************/
  11.  
  12. /*    TESample.c and TESample.r include this file. */
  13.  
  14. /* ••• The following lines were added for XTND ••• */
  15.  
  16. #define thePort        qd.thePort
  17. #define screenBits    qd.screenBits
  18. #define arrow        qd.arrow
  19.  
  20. #ifdef THINK_C
  21. /**
  22.     Defines needed to compile in Think C
  23. **/
  24.     #define DlgHookProcPtr ProcPtr
  25.     #define ClikLoopProcPtr ProcPtr
  26.     #define    hfileInfo    hFileInfo
  27.  
  28.     #define normal            0
  29.     #define NIL                0L
  30.     #define null            0L
  31. /*    #define MAXLONG            0x7FFFFFFF */
  32. /*    #define RGBColor        _RGBColor  */
  33.  
  34. #else
  35. /**
  36.     Minimum set of defines needed to compile in MPW
  37. **/
  38.  
  39.     #define black        qd.black
  40.     #define white        qd.white
  41.     #define gray        qd.gray
  42.     #define dkgray        qd.dkGray
  43.     #define hFileInfo    hfileInfo    /* Spelled wrong in MPW headers */
  44.     #define PtoCstr        p2cstr
  45.     
  46.     #define topLeft(r)    (((Point *) &(r))[0])
  47.     #define botRight(r)    (((Point *) &(r))[1])
  48.     
  49.     /**
  50.         Other stuff that is not defined by MPW
  51.     **/
  52.     
  53.     #define NIL        0L
  54.     #define null    0L
  55.     
  56.     #define MAX(a, b) (a > b ? a : b)
  57.     #define MIN(a, b) (a < b ? a : b)
  58.     
  59.     #define WUNDERLINE            0x1000
  60.     #define DUNDERLINE            0x2000
  61.  
  62. #endif
  63.     
  64.  
  65. #define kTransVersion 2        /* Version of XTND used by TESample (Version 2 is XTND 1.3) */
  66.  
  67. #define kPrefSize                512        /* Give the application enough memory to avoid running out */
  68. #define kMinSize                128
  69.  
  70.  
  71. /* ———— Defines for XTND resources ———— */
  72.  
  73. #define clarisNames            25003    /* Claris names STR# resource */
  74. #define clarisFolder        1
  75. #define xtndNames            25004    /* XTND names STR# resource */
  76. #define clarisTranslators    1
  77. #define xtndSystem            2
  78.  
  79.  
  80. #ifndef __TE_Sample_Res__    /* Don't define this when included in TESample.r */
  81.  
  82. /* A DocumentRecord contains the WindowRecord for one of our document windows,
  83.    as well as the TEHandle for the text we are editing. Other document fields
  84.    can be added to this record as needed. For a similar example, see how the
  85.    Window Manager and Dialog Manager add fields after the GrafPort. */
  86. typedef struct {
  87.     WindowRecord    docWindow;
  88.     TEHandle        docTE;
  89.     ControlHandle    docVScroll;
  90.     ControlHandle    docHScroll;
  91.     ProcPtr            docClik;
  92. } DocumentRecord, *DocumentPeek;
  93.  
  94. #endif
  95.  
  96. /* ••• End of XTND additions ••• */
  97.  
  98.  
  99. /* The following constants are used to identify menus and their items. The menu IDs
  100.    have an "m" prefix and the item numbers within each menu have an "i" prefix. */
  101. #define    mApple                    128        /* Apple menu */
  102. #define    iAbout                    1
  103.  
  104. #define    mFile                    129        /* File menu */
  105. #define    iNew                    1
  106. #define    iOpen                    2
  107. #define    iClose                    4
  108. #define    iSave                    5
  109. #define    iSaveAs                    6
  110. #define    iQuit                    12
  111.  
  112. #define    mEdit                    130        /* Edit menu */
  113. #define    iUndo                    1
  114. #define    iCut                    3
  115. #define    iCopy                    4
  116. #define    iPaste                    5
  117. #define    iClear                    6
  118.  
  119. #define    mFont                    131
  120. /* Font menu - no items */
  121.  
  122. #define    mSize                    132
  123. #define    iPoints                    1
  124. #define    iSizeVal                2
  125.  
  126. /*    1.01 - kTopLeft - This is for positioning the Disk Initialization dialogs. */
  127.  
  128. #define kDITop                    0x0050
  129. #define kDILeft                    0x0070
  130.  
  131. /* 1.01 - changed constants to begin with 'k' for consistency, except for resource IDs */
  132. /*    kTextMargin is the number of pixels we leave blank at the edge of the window. */
  133. #define kTextMargin                2
  134.  
  135. /* kMaxOpenDocuments is used to determine whether a new document can be opened
  136.    or created. We keep track of the number of open documents, and disable the
  137.    menu items that create a new document when the maximum is reached. If the
  138.    number of documents falls below the maximum, the items are enabled again. */
  139. #define    kMaxOpenDocuments        8
  140.     
  141. /*    kMaxDocWidth is an arbitrary number used to specify the width of the TERec's
  142.     destination rectangle so that word wrap and horizontal scrolling can be
  143.     demonstrated. */
  144. #define    kMaxDocWidth            576
  145.     
  146. /* kMinDocDim is used to limit the minimum dimension of a window when GrowWindow
  147.     is called. */
  148. #define    kMinDocDim                64
  149.  
  150. /*    kControlInvisible is used to 'turn off' controls (i.e., cause the control not
  151.     to be redrawn as a result of some Control Manager call such as SetCtlValue)
  152.     by being put into the contrlVis field of the record. kControlVisible is used
  153.     the same way to 'turn on' the control. */
  154. #define kControlInvisible        0
  155. #define kControlVisible            0xFF
  156.  
  157. /*    kScrollbarAdjust and kScrollbarWidth are used in calculating
  158.     values for control positioning and sizing. */
  159. #define kScrollbarWidth            16
  160. #define kScrollbarAdjust        (kScrollbarWidth - 1)
  161.  
  162. /*    kScrollTweek compensates for off-by-one requirements of the scrollbars
  163.  to have borders coincide with the growbox. */
  164. #define kScrollTweek            2
  165.     
  166. /*    kCrChar is used to match with a carriage return when calculating the
  167.     number of lines in the TextEdit record. kDelChar is used to check for
  168.     delete in keyDowns. */
  169. #define kCrChar                    13
  170. #define kDelChar                8
  171.     
  172. /*    kButtonScroll is how many pixels to scroll horizontally when the button part
  173.     of the horizontal scrollbar is pressed. */
  174. #define kButtonScroll            12
  175.     
  176. /*    kMaxTELength is an arbitrary number used to limit the length of text in the TERec
  177.     so that various errors won't occur from too many characters in the text. */
  178. #define    kMaxTELength            32000
  179.  
  180. /* kSysEnvironsVersion is passed to SysEnvirons to tell it which version of the
  181.    SysEnvRec we understand. */
  182. #define    kSysEnvironsVersion        1
  183.  
  184. /* kOSEvent is the event number of the suspend/resume and mouse-moved events sent
  185.    by MultiFinder. Once we determine that an event is an OSEvent, we look at the
  186.    high byte of the message sent to determine which kind it is. To differentiate
  187.    suspend and resume events we check the resumeMask bit. */
  188. #define    kOSEvent                app4Evt    /* event used by MultiFinder */
  189. #define    kSuspendResumeMessage    1        /* high byte of suspend/resume event message */
  190. #define    kResumeMask                1        /* bit of message field for resume vs. suspend */
  191. #define    kMouseMovedMessage        0xFA    /* high byte of mouse-moved event message */
  192. #define    kNoEvents                0        /* no events mask */
  193.  
  194. /* 1.01 - kMinHeap - This is the minimum result from the following
  195.      equation:
  196.             
  197.             ORD(GetApplLimit) - ORD(ApplicZone)
  198.             
  199.      for the application to run. It will insure that enough memory will
  200.      be around for reasonable-sized scraps, FKEYs, etc. to exist with the
  201.      application, and still give the application some 'breathing room'.
  202.      To derive this number, we ran under a MultiFinder partition that was
  203.      our requested minimum size, as given in the 'SIZE' resource. */
  204.      
  205. #define    kMinHeap                 (29 * 1024)
  206.     
  207. /* 1.01 - kMinSpace - This is the minimum result from PurgeSpace, when called
  208.      at initialization time, for the application to run. This number acts
  209.      as a double-check to insure that there really is enough memory for the
  210.      application to run, including what has been taken up already by
  211.      pre-loaded resources, the scrap, code, and other sundry memory blocks. */
  212.      
  213. #define    kMinSpace                (20 * 1024)
  214.  
  215. /*    kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */
  216. #define kExtremeNeg                -32768
  217. #define kExtremePos                (32767 - 1)    /* required to address an old region bug */
  218.     
  219. /* kTESlop provides some extra security when pre-flighting edit commands. */
  220. #define    kTESlop                    1024
  221.  
  222. /* The following are indicies into STR# resources. */
  223. #define    eWrongMachine            1
  224. #define    eSmallSize                2
  225. #define    eNoMemory                3
  226. #define    eNoSpaceCut                4
  227. #define    eNoCut                    5
  228. #define    eNoCopy                    6
  229. #define    eExceedPaste            7
  230. #define    eNoSpacePaste            8
  231. #define    eNoWindow                9
  232. #define    eExceedChar                10
  233. #define    eNoPaste                11
  234.  
  235. /* Some CLSF errors */
  236.  
  237. #define    eTranslatorOpen            12
  238. #define    eTranslatorLoad            13
  239. #define    eResFailed                14
  240. #define    eResReadFail            15
  241. #define    eDocOpenFail            16
  242. #define    eDocReadFail            17
  243. #define    eDeleteFailed            18
  244. #define    eCreateFail                19
  245. #define    eOpenFail                20
  246.  
  247. #define    rMenuBar    128                /* application's menu bar */
  248. #define    rAboutAlert    128                /* about alert */
  249. #define    rUserAlert    129                /* user error alert */
  250. #define    rDocWindow    128                /* application's window */
  251. #define    rVScroll    128                /* vertical scrollbar control */
  252. #define    rHScroll    129                /* horizontal scrollbar control */
  253. #define    kErrStrings    128                /* error string list */
  254.